<!doctype HTML public "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- Click to Convert 5.2: Anything to HTML -->
<!-- http://www.clicktoconvert.com -->

<html>
<head>
<title>gravityboxscheduleuserguide - page 39 of 234</title>
<meta http-equiv=content-type content=text/html;charset=iso-8859-1>
<meta name="Generator" content="Click to Convert">

<!--Start of page styles-->
<STYLE TYPE="text/css">
<!--
 /* Foreground Image Styles */

 /* Position Styles */
 .ts39p0{position:absolute;left:106px;top:97px;}
 .ts39p1{position:absolute;left:352px;top:97px;}
 .ts39p3{position:absolute;left:672px;top:97px;}
 .ts39p7{position:absolute;left:106px;top:113px;}
 .ts39p8{position:absolute;left:706px;top:1026px;}
 .ts39p9{position:absolute;left:331px;top:1044px;}
 .ts39p13{position:absolute;left:106px;top:146px;}
 .ts39p15{position:absolute;left:106px;top:220px;}
 .ts39p18{position:absolute;left:106px;top:256px;}
 .ts39p19{position:absolute;left:106px;top:275px;}
 .ts39p20{position:absolute;left:106px;top:293px;}
 .ts39p21{position:absolute;left:106px;top:312px;}
 .ts39p23{position:absolute;left:106px;top:330px;}
 .ts39p24{position:absolute;left:106px;top:348px;}
 .ts39p26{position:absolute;left:106px;top:367px;}
 .ts39p27{position:absolute;left:106px;top:385px;}
 .ts39p29{position:absolute;left:106px;top:422px;}
 .ts39p31{position:absolute;left:106px;top:440px;}
 .ts39p32{position:absolute;left:106px;top:459px;}
 .ts39p33{position:absolute;left:106px;top:477px;}
 .ts39p35{position:absolute;left:106px;top:496px;}
 .ts39p36{position:absolute;left:106px;top:514px;}
 .ts39p37{position:absolute;left:106px;top:532px;}
 .ts39p39{position:absolute;left:106px;top:551px;}
 .ts39p41{position:absolute;left:106px;top:569px;}
 .ts39p42{position:absolute;left:106px;top:588px;}
 .ts39p43{position:absolute;left:106px;top:606px;}
 .ts39p44{position:absolute;left:106px;top:624px;}
 .ts39p46{position:absolute;left:106px;top:643px;}
 .ts39p47{position:absolute;left:106px;top:661px;}
 .ts39p49{position:absolute;left:106px;top:680px;}
 .ts39p50{position:absolute;left:106px;top:699px;}
 .ts39p53{position:absolute;left:106px;top:717px;}
 .ts39p55{position:absolute;left:106px;top:735px;}
 .ts39p56{position:absolute;left:106px;top:754px;}
 .ts39p57{position:absolute;left:106px;top:772px;}
 .ts39p58{position:absolute;left:106px;top:791px;}
 .ts39p59{position:absolute;left:106px;top:809px;}
 .ts39p61{position:absolute;left:106px;top:828px;}
 .ts39p62{position:absolute;left:106px;top:846px;}
 .ts39p64{position:absolute;left:106px;top:864px;}
 .ts39p65{position:absolute;left:106px;top:884px;}
 .ts39p67{position:absolute;left:106px;top:902px;}
 .ts39p69{position:absolute;left:106px;top:920px;}
 .ts39p70{position:absolute;left:106px;top:939px;}
 .ts39p71{position:absolute;left:106px;top:957px;}
 .ts39p72{position:absolute;left:106px;top:976px;}

 /* Font Styles */
 .ft0p39{font-style:normal;font-weight:bold;font-size:13px;font-family:arial,sans-serif;color:#000000;}
 .ft1p39{font-weight:normal;}
 .ft2p39{font-style:normal;font-weight:normal;font-size:13px;font-family:"times new roman","times new roman",times,serif;color:#000000;}
 .ft3p39{font-style:normal;font-weight:normal;font-size:16px;font-family:"times new roman","times new roman",times,serif;color:#000000;}
 .ft4p39{font-style:normal;font-weight:bold;font-size:11px;font-family:arial,sans-serif;color:#000000;}
 .ft5p39{font-style:normal;font-weight:normal;font-size:32px;font-family:helvetica,arial,sans-serif;color:#000000;}
 .ft6p39{font-style:normal;font-weight:bold;font-size:21px;font-family:arial,sans-serif;color:#808080;}
 .ft7p39{font-style:normal;font-weight:normal;font-size:16px;font-family:arial,sans-serif;color:#000000;}
 .ft8p39{font-style:normal;font-weight:normal;font-size:16px;font-family:"courier new",courier,monospace;color:#000000;}

 /* Background Style */
 .styleBackground39{position:absolute;left:97px;top:697px}

 /* Navigation Styles */
 .styleNavBarTop{position:absolute;left:0px;top:2px}
 .nb{position:absolute;left:2px;top:0px}
 .nbs{position:absolute;left:0px;top:0px}
 .nbe{position:absolute;left:836px;top:0px}
 .styleNavBarBot{position:absolute;left:0px;top:1117px}
-->
</STYLE>
<!--End of page styles-->

</head>
<body bgcolor="#ffffff" text="#000000" link="#0000FF" Vlink="#660099">

<table id="pageTable" width="836" STYLE="position: relative; left: auto; top: auto;"><tr><td>
<div class=nbs><img src="./navbarstart.gif" width="2" height="30"></div>
<div class=nb><img src="./navbar.gif" width="836" height="30" alt="Navigation bar"></div>
<div class=nbe><img src="./navbarend.gif" width="2" height="30"></div>
<div class=styleNavBarTop>
<table width="834" height="26" border="0" cellspacing="0">
  <tr align="left">
    <td width="4">&nbsp;</td>
    <td width="25" align="center"><a href="http://www.gravitybox.com" target="_parent"><img src="./home.gif" border="0" alt="Home"></a></td>
    <td width="25" align="center"><a href="#" onClick="window.open('./print.html','Printing','width=300,height=100,toolbar=no,directories=no');return false;"><img src="./print.gif" border="0" alt="Print document"></a></td>
    <td width="10" align="center"><img src="./separator.gif" border="0"></td>
    <td width="18" align="center"><a href="./index1.html"><img src="./start.gif" width="18" height="14" border="0" alt="Start"></a></td>
    <td width="18" align="center"><a href="./index38.html"><img src="./back.gif" width="14" height="14" border="0" alt="Previous page"></a></td>
    <td width="80" valign="middle"><table width="100%" height="16" border="0" cellspacing="1" bgcolor="#ACA899"><tr><td align="center" bgcolor="#ffffff"><font face=verdana,arial,sans-serif><font size="1">&nbsp;39 of 234&nbsp;</font></font></td></tr></table></td>
    <td width="18" align="center"><a href="./index40.html"><img src="./forward.gif" width="14" height="14" border="0" alt="Next page"></a></td>
    <td width="18" align="center"><a href="./index234.html"><img src="./end.gif" width="18" height="14" border="0" alt="End"></a></td>
    <td width="620">&nbsp;</td>
  </tr>
</table>
<p>
</div>
<nobr>
<div class=styleBackground39><img src="./background39.png" width="633" height="358" border="0" alt=""></div>
<div class=ts39p0><span class="ft0p39"> </span></div>
<div class=ts39p1><span class="ft0p39">Gravitybox Schedule Primer<span class="ft1p39"> </span></span></div>
<div class=ts39p3><span class="ft0p39">Page 37&nbsp; </span></div>
<div class=ts39p7><span class="ft2p39"> </span></div>
<div class=ts39p8><span class="ft3p39"> </span></div>
<div class=ts39p9><span class="ft4p39">1998&#45;2004 Gravitybox Software LLC<span class="ft3p39"> </span></span></div>
<div class=ts39p13><span class="ft5p39">Chapter 3 </span></div>
<div class=ts39p15><span class="ft6p39">Adding Code </span></div>
<div class=ts39p18><span class="ft7p39">So far we have created and application with a schedule in it. We have learned to create </span></div>
<div class=ts39p19><span class="ft7p39">an application with multiple schedules in it and move appointment between those </span></div>
<div class=ts39p20><span class="ft7p39">schedules. However we have not as of yet added any code. Now creating these </span></div>
<div class=ts39p21><span class="ft7p39">schedules are nice, but without code, we can really build nothing but trivial applications. </span></div>
<div class=ts39p23><span class="ft7p39">Chapter 1 showed how to set some other the properties but now we need to learn how </span></div>
<div class=ts39p24><span class="ft7p39">to add code and use some of the events. </span></div>
<div class=ts39p26><span class="ft7p39"> </span></div>
<div class=ts39p27><span class="ft6p39">Reference Creation </span></div>
<div class=ts39p29><span class="ft7p39">We will begin by looking at the ScheduleItems collection, since this collection is the </span></div>
<div class=ts39p31><span class="ft7p39">most frequently used. The collection has an Add method that allows for the addition of a </span></div>
<div class=ts39p32><span class="ft7p39">new element to the collection. Many properties may be set as parameters in the method </span></div>
<div class=ts39p33><span class="ft7p39">call. There are some exceptions and this is the reason for creating an object reference </span></div>
<div class=ts39p35><span class="ft7p39">to each. In collections, all of the properties of an object may not be set from its parent </span></div>
<div class=ts39p36><span class="ft7p39">Add method. To set all properties would be cumbersome for objects with many </span></div>
<div class=ts39p37><span class="ft7p39">properties and would break compatibility, if more properties were added in future </span></div>
<div class=ts39p39><span class="ft7p39">versions. </span></div>
<div class=ts39p41><span class="ft7p39"> </span></div>
<div class=ts39p42><span class="ft7p39">There is no parameter in the Add method to set the Id property of a ScheduleItem. An </span></div>
<div class=ts39p43><span class="ft7p39">object reference must be made to set the property contents of the newly added object. </span></div>
<div class=ts39p44><span class="ft7p39">The following code will add an appointment, to the ScheduleItems collection, with the </span></div>
<div class=ts39p46><span class="ft7p39">name of &#147;Appt1&#148;. It will be scheduled on June 3, 2002 in Room 1 at 8:00 AM. It will </span></div>
<div class=ts39p47><span class="ft7p39">display the text &#147;John Doe's Appointment&#148; on the screen. </span></div>
<div class=ts39p49><span class="ft7p39"> </span></div>
<div class=ts39p50><span class="ft8p39">Call Schedule1.ScheduleItems.Add(&#34;Appt1&#34;, #6/3/2002#, 1, _ </span></div>
<div class=ts39p53><span class="ft8p39">#8:00:00 AM#, 60, &#34;John Doe's Appointment&#34;)<span class="ft7p39"> </span></span></div>
<div class=ts39p55><span class="ft7p39"> </span></div>
<div class=ts39p56><span class="ft7p39"> </span></div>
<div class=ts39p57><span class="ft7p39">As can be seen, there is no parameter to set the Id property, in the Add method. The </span></div>
<div class=ts39p58><span class="ft7p39">developer must reference the last added element and set it. This may be done with the </span></div>
<div class=ts39p59><span class="ft7p39">following code. The Count method returns the total number of item in its collection. </span></div>
<div class=ts39p61><span class="ft7p39">Since the object was the last one added, it will be the last one in the collection. The Id </span></div>
<div class=ts39p62><span class="ft7p39">property may then be referenced and its value set. </span></div>
<div class=ts39p64><span class="ft7p39"> </span></div>
<div class=ts39p65><span class="ft8p39">Schedule1.ScheduleItems(Schedule1.ScheduleItems.Count).Id = </span></div>
<div class=ts39p67><span class="ft8p39">newId<span class="ft7p39"> </span></span></div>
<div class=ts39p69><span class="ft7p39"> </span></div>
<div class=ts39p70><span class="ft7p39">This syntax is rather cumbersome and could get very messy, if several properties </span></div>
<div class=ts39p71><span class="ft7p39">needed to be set. Also, it issues at least 4 object lookups to find the element. When </span></div>
<div class=ts39p72><span class="ft7p39">setting many properties, this syntax would create slow code very quickly, not to mention </span></div>
<div class=styleNavBarBot>
<table width="836" border="0" cellspacing="2">
  <tr></tr>
  <tr>
    <td width="118"><a href="http://www.purepage.com"><img src="./smalllogo.gif" width="118" height="46" border="0" alt="http://www.purepage.com"></a></td>
    <td></td>
  </tr>
</table>
</div>

</td></tr></table>

</body>
</html>
